package com.xigua._排序;

import java.util.Arrays;
import java.util.Collections;

/**
 * @author LiRongHua
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2022/3/2013:47
 */
public class _剑指Offer45_把数组排成最小的数 {

    public static void main(String[] args) {
        minNumber(new int[]{3,30,34,5,9});
    }

    public static String minNumber(int[] nums) {
        String ans[] = new String[nums.length];
        for (int i = 0; i < ans.length; i++) {
            ans[i] = String.valueOf(nums[i]);
        }
        Arrays.sort(ans,(o1, o2) -> {
            return (o1+o2).compareTo(o2+o1);
        });
        StringBuffer res = new StringBuffer();
        for (String an : ans) {
            res.append(an);
        }
        return res.toString();
    }

}
